jsx3.require("tibco.admin.enterpriseAssets.EnterpriseAssetsTabInterface");

/*
 *
 */
jsx3.lang.Package.definePackage("tibco.admin.enterpriseAssets.shdResDefs", function (shdResDefs) {
});

/*
 *
 */
jsx3.Class.defineClass(
        "tibco.admin.enterpriseAssets.shdResDefs.ShdResDefs",
        jsx3.lang.Object,
        [tibco.admin.enterpriseAssets.EnterpriseAssetsTabInterface, tibco.admin.plugin.PluginContainerInterface],
        function (plugin) {

            plugin.imagesForType = new Object();
            plugin.stringsForType = new Object();
            plugin.prototype.selection = new jsx3.util.List(0);

            // Implementation of the PluginContainerInterface
            plugin.prototype.setupPlugin = function(obj) {
            }

            plugin.prototype.getImageForType = function(type) {
                var ret = plugin.imagesForType[type];
                if(!ret) {
                    var iter = this.getPluginList().iterator();
                    while(iter.hasNext()) {
                        var item = iter.next();
                        if(item.getType() == type) {
                            ret = "" + item.getImagePath();
                            if(!ret) {
                                ret = tibco.admin.Main.getServer().getDynamicProperty("@addin@Blank Icon Path");
                            }
                            else {
                                plugin.imagesForType[type] = ret;
                            }
                        }
                    }
                }
                if(!ret) {
                    ret = tibco.admin.Main.getServer().getDynamicProperty("@addin@Blank Icon Path");
                }
                return ret;
            }

            plugin.prototype.getDisplayStringForType = function(type) {
                var ret = plugin.stringsForType[type];
                if(!ret) {
                    var iter = this.getPluginList().iterator();
                    while(iter.hasNext()) {
                        var item = iter.next();
                        if(item.getType() == type) {
                            ret = "" + item.getAddText();
                            if(!ret) {
                                ret = type
                            }
                            else {
                                plugin.stringsForType[type] = ret;
                            }
                        }
                    }
                }
                if(!ret) {
                    ret = type;
                }
                return ret;
            }

            plugin.prototype.onAfterGetPlugins = function() {
                var addMenu = this.mainComponent.getDescendantOfName("mnbAdd_25A");
                var me = this;
                addMenu.subscribe(jsx3.gui.Interactive.SELECT, me, me.add);
                var iter = this.getPluginList().iterator();
                while(iter.hasNext()) {
                    var obj = iter.next();
                    var actionAdd = new Object();
                    actionAdd.jsxtext = obj.getAddText();
                    actionAdd.jsximg = tibco.admin.Main.resolveImageRelativeToAdmin("" + obj.getImagePath());
                    actionAdd.jsxid = obj.getType() + Math.floor(Math.random() * 1000000 + 1);
                    actionAdd.type = obj.getType();
                    addMenu.insertRecord(actionAdd, "jsxroot", false);
                }
                addMenu.repaint();
            }
            // End implementation of the PluginContainerInterface

            // Implementation of the EnterpriseAssetsTabInterface
            plugin.instance = null

            plugin.prototype.getNamespace = function () {
                return "tibco.admin";
            }

            plugin.prototype.initPlugin = function() {
                if(!tibco.admin.enterpriseAssets.shdResDefs.ShdResDefDetails) {
                    tibco.admin.Main.loadClass("tibco/admin/enterpriseAssets/shdResDefs/ShdResDefDetails.js",
                            this.getNamespace());
                }
                if(!tibco.admin.enterpriseAssets.shdResDefs.ShdResDefPicker) {
                    tibco.admin.Main.loadClass("tibco/admin/enterpriseAssets/shdResDefs/ShdResDefPicker.js",
                            this.getNamespace());
                }
            }

            plugin.prototype.destroyPlugin = function() {
            }

            plugin.getInstance = function(args) {
                if(!this.instance) {
                    this.instance = new tibco.admin.enterpriseAssets.shdResDefs.ShdResDefs();
                }
                return this.instance;
            }

            plugin.prototype.getComponentPath = function() {
                return  "tibco/admin/enterpriseAssets/shdResDefs/component.xml"
            }

            plugin.prototype.loadComponent = function(parent) {
                var me = this;
                tibco.admin.Main.loadUIResourceAsync(parent, this.getNamespace(),
                        "tibco/admin/enterpriseAssets/shdResDefs/components/shdResDefs.xml",
                        me, me.initialize);
            }

            plugin.prototype.getTabText = function() {
                return tibco.admin.Main.getServer().getDynamicProperty("@@SharedResourcesDefinitions_20")
            }
            // End implementation of the EnterpriseAssetsTabInterface


            // Component handling

            plugin.prototype.mainComponent = null;
            plugin.prototype.matrix = null;
            plugin.prototype.details = null;

            plugin.prototype.masterRefreshing = false;

            // TODO: Code reuse from LGA's sharedConfigsInEnvironment

            plugin.ONADD = "tibco.admin.enterpriseAssets.shdResDefs.ADDITEM";
            plugin.ONITEMSELECTED = "tibco.admin.enterpriseAssets.shdResDefs.ITEMSELECTED";
            plugin.ONDELETE = "tibco.admin.enterpriseAssets.shdResDefs.ITEMDELETED";
            plugin.ONREFRESH = "tibco.admin.enterpriseAssets.shdResDefs.REFRESH";

            plugin.ONSETPERMISSIONS = "tibco.admin.enterpriseAssets.shdResDefs.SETPERMISSIONS";
            plugin.ONDELPERMISSIONS = "tibco.admin.enterpriseAssets.shdResDefs.DELPERMISSIONS";

            plugin.prototype.initialize = function(objEvent) {
                if(objEvent.status == "SUCCESS") {
                    this.mainComponent = objEvent.obj;
                    this.mainComponent.handler = this;
                    if(!tibco.admin.enterpriseAssets.shdResDefs.ShdResDefDetails) {
                        tibco.admin.Main.loadClass("tibco/admin/enterpriseAssets/shdResDefs/ShdResDefDetails.js",
                                "tibco.admin");
                    }
                    // load plugins
                    if(this.getPluginList().size() == 0) {
                        var preLoad = new jsx3.util.List(0);

                        // load bundled shared resource definitions
                        // TODO: add RV, SSL
                        if(!tibco.admin.enterpriseAssets.shdResDefs.HTTP || !tibco.admin.enterpriseAssets.shdResDefs.HTTP.ShdHttpResDefs) {
                            try {
                                tibco.admin.Main.loadClass("tibco/admin/enterpriseAssets/shdResDefs/HTTP/ShdHttpResDefs.js", this.getNamespace());
                                preLoad.add(tibco.admin.enterpriseAssets.shdResDefs.HTTP.ShdHttpResDefs, preLoad.size());
                            }
                            catch(ex) {
                                tibco.admin.Main.logException(ex);
                            }
                        }
                        else {
                            preLoad.add(tibco.admin.enterpriseAssets.shdResDefs.HTTP.ShdHttpResDefs, preLoad.size());
                        }
                        if(!tibco.admin.enterpriseAssets.shdResDefs.Identity || !tibco.admin.enterpriseAssets.shdResDefs.Identity.ShdIdentityResDefs) {
                            try {
                                tibco.admin.Main.loadClass("tibco/admin/enterpriseAssets/shdResDefs/Identity/ShdIdentityResDefs.js", this.getNamespace());
                                preLoad.add(tibco.admin.enterpriseAssets.shdResDefs.Identity.ShdIdentityResDefs, preLoad.size());
                            }
                            catch(ex) {
                                tibco.admin.Main.logException(ex);
                            }
                        }
                        else {
                            preLoad.add(tibco.admin.enterpriseAssets.shdResDefs.Identity.ShdIdentityResDefs, preLoad.size());
                        }
                        if(!tibco.admin.enterpriseAssets.shdResDefs.JDBC || !tibco.admin.enterpriseAssets.shdResDefs.JDBC.ShdJdbcResDefs) {
                            try {
                                tibco.admin.Main.loadClass("tibco/admin/enterpriseAssets/shdResDefs/JDBC/ShdJdbcResDefs.js", this.getNamespace());
                                preLoad.add(tibco.admin.enterpriseAssets.shdResDefs.JDBC.ShdJdbcResDefs, preLoad.size());
                            }
                            catch(ex) {
                                tibco.admin.Main.logException(ex);
                            }
                        }
                        else {
                            preLoad.add(tibco.admin.enterpriseAssets.shdResDefs.JDBC.ShdJdbcResDefs, preLoad.size());
                        }
                        if(!tibco.admin.enterpriseAssets.shdResDefs.EMS || !tibco.admin.enterpriseAssets.shdResDefs.EMS.ShdEmsResDefs) {
                            try {
                                tibco.admin.Main.loadClass("tibco/admin/enterpriseAssets/shdResDefs/EMS/ShdEmsResDefs.js", this.getNamespace());
                                preLoad.add(tibco.admin.enterpriseAssets.shdResDefs.EMS.ShdEmsResDefs, preLoad.size());
                            }
                            catch(ex) {
                                tibco.admin.Main.logException(ex);
                            }
                        }
                        else {
                            preLoad.add(tibco.admin.enterpriseAssets.shdResDefs.EMS.ShdEmsResDefs, preLoad.size());
                        }
                        if(!tibco.admin.enterpriseAssets.shdResDefs.JNDI || !tibco.admin.enterpriseAssets.shdResDefs.JNDI.ShdJndiResDefs) {
                            try {
                                tibco.admin.Main.loadClass("tibco/admin/enterpriseAssets/shdResDefs/JNDI/ShdJndiResDefs.js", this.getNamespace());
                                preLoad.add(tibco.admin.enterpriseAssets.shdResDefs.JNDI.ShdJndiResDefs, preLoad.size());
                            }
                            catch(ex) {
                                tibco.admin.Main.logException(ex);
                            }
                        }
                        else {
                            preLoad.add(tibco.admin.enterpriseAssets.shdResDefs.JNDI.ShdJndiResDefs, preLoad.size());
                        }
                        if(!tibco.admin.enterpriseAssets.shdResDefs.RV || !tibco.admin.enterpriseAssets.shdResDefs.RV.ShdRVResDefs) {
                            try {
                                tibco.admin.Main.loadClass("tibco/admin/enterpriseAssets/shdResDefs/RV/ShdRVResDefs.js", this.getNamespace());
                                preLoad.add(tibco.admin.enterpriseAssets.shdResDefs.RV.ShdRVResDefs, preLoad.size());
                            }
                            catch(ex) {
                                tibco.admin.Main.logException(ex);
                            }
                        }
                        else {
                            preLoad.add(tibco.admin.enterpriseAssets.shdResDefs.RV.ShdRVResDefs, preLoad.size());
                        }
                        if(!tibco.admin.enterpriseAssets.shdResDefs.ServerSSL || !tibco.admin.enterpriseAssets.shdResDefs.ServerSSL.ShdSSLServerResDefs) {
                            try {
                                tibco.admin.Main.loadClass("tibco/admin/enterpriseAssets/shdResDefs/ServerSSL/ShdSSLServerResDefs.js", this.getNamespace());
                                preLoad.add(tibco.admin.enterpriseAssets.shdResDefs.ServerSSL.ShdSSLServerResDefs, preLoad.size());
                            }
                            catch(ex) {
                                tibco.admin.Main.logException(ex);
                            }
                        }
                        else {
                            preLoad.add(tibco.admin.enterpriseAssets.shdResDefs.ServerSSL.ShdSSLServerResDefs, preLoad.size());
                        }
                        /* remove SSL client
                        if (!tibco.admin.enterpriseAssets.shdResDefs.ClientSSL || !tibco.admin.enterpriseAssets.shdResDefs.ClientSSL.ShdSSLClientResDefs) {
                            try {
                                tibco.admin.Main.loadClass("tibco/admin/enterpriseAssets/shdResDefs/ClientSSL/ShdSSLClientResDefs.js", this.getNamespace());
                                preLoad.add(tibco.admin.enterpriseAssets.shdResDefs.ClientSSL.ShdSSLClientResDefs, preLoad.size());
                            }
                            catch(ex) {
                                tibco.admin.Main.logException(ex);
                            }
                        }
                        else {
                            preLoad.add(tibco.admin.enterpriseAssets.shdResDefs.ClientSSL.ShdSSLClientResDefs, preLoad.size());
                        }*/
                        this.loadPlugins("tibco.admin.enterpriseAssets.shdResDefs.ShdResDefsInterface", preLoad);
                    }
                    else {
                        this.onAfterGetPlugins();
                    }

                    this.matrix = this.mainComponent.getDescendantOfName("mtxListShdResDefs_25A");
                    var me = this;
                    this.matrix.subscribe(plugin.ONITEMSELECTED, me, me.nodeSelected);
                    var button = this.mainComponent.getDescendantOfName("btnDelete_25A");
                    button.subscribe(plugin.ONDELETE, me, me.onDelete);
                    button = this.mainComponent.getDescendantOfName("btnRefresh_25A");
                    button.subscribe(plugin.ONREFRESH, me, me.onRefresh);

                    this.callGetConfigurationsInEnterprise();

                    this.initTypeFilter();
                    //========= Alex: add button event of set permissions ====================
                    // Modified: ramin
                    // Date: 07-09-2007
                    this.loadPermissionButtons();
                    //============================ end =========================================

                }
                else {
                    tibco.admin.util.Log.ENVIRONMENT.error(tibco.admin.Main.getServer().getDynamicProperty("@LoadUIComponentErrorMsg", objEvent.message));
                }
            }

            plugin.prototype.initTypeFilter = function() {
                var strAllTypes = tibco.admin.Main.getServer().getDynamicProperty("@AllTypes");
                this.mainComponent.getDescendantOfName("selFilterType").setValue(strAllTypes);
                this.mainComponent.getDescendantOfName("selFilterType").insertRecord({jsxid:strAllTypes, jsxtext:strAllTypes}, null, true);
                var iter = this.getPluginList().iterator();
                while(iter.hasNext()) {
                    var obj = iter.next();
                    this.mainComponent.getDescendantOfName("selFilterType").insertRecord({jsxid:obj.getType(), jsxtext:obj.getAddText()}, null, true);
                }
            }

            plugin.prototype.onDelete = function() {
                // TODO: really useful? Delete should be disabled if no selection!
                if(this.matrix.getSelectedNodes().size() > 0) {
                    var me = this;
                    var yesFunction = function(dialog) {
                        me.reallyDelete();
                        dialog.doClose();
                    }
                    tibco.admin.Main.confirm(tibco.admin.Main.getServer().getDynamicProperty("@ConfirmDelete"),
                            tibco.admin.Main.getServer().getDynamicProperty("@ConfirmDeleteMsg"),
                            yesFunction, null, tibco.admin.Main.getServer().getDynamicProperty("@addin@Btn Yes"),
                            tibco.admin.Main.getServer().getDynamicProperty("@addin@Btn No"));
                }
            };

            // TODO: ask Joel how he handled this...
            plugin.prototype.reallyDelete = function(dialog) {
                var parent = this.mainComponent.getDescendantOfName("paneShdResDefsDetails_25");
                parent.removeChildren();
                this.details = null;
                var nodes = this.matrix.getSelectedNodes();
                var objDoc = jsx3.xml.CDF.newDocument();
                var rec;
                for(var i = 0; i < nodes.size(); i++) {
                    rec = objDoc.createNode(jsx3.xml.Entity.TYPEELEMENT, 'record');
                    rec.setAttribute('name', nodes.getItem(i).getAttribute('name'));
                    rec.setAttribute('EntityID', nodes.getItem(i).getAttribute('entityID'));
                    objDoc.appendChild(rec);
                    this.matrix.deleteRecord(nodes.getItem(i).getAttribute('jsxid'));
                }
                this.matrix.repaint();
                tibco.admin.Main.getServer().Cache.setDocument("xmlCacheIDSelectedShdResDefs_25A", objDoc);
                this.callremoveResourceConfigs();
            };

            plugin.prototype.onRefresh = function() {
                this.refreshList();
            };

            plugin.prototype.refreshList = function() {
                // TODO: sanity check on ongoing operations
                this.callGetConfigurationsInEnterprise();
            }

            plugin.prototype.nodeSelected = function(objEvent) {
                if(this.ignoreSelects) {
                    var cacheDoc = this.matrix.getXML();
                    if(cacheDoc) {
                        var recordIter = cacheDoc.getXML().selectNodes("//record[@jsxselected='1']");
                        while(recordIter.hasNext()) {
                            var record = recordIter.next();
                            record.setAttribute("jsxselected", 0);
                        }
                        var iter = this.selection.iterator();
                        while(iter.hasNext()) {
                            var name = iter.next();
                            var record = cacheDoc.getXML().selectSingleNode("//record[@name='" + name + "']");
                            if(record) {
                                record.setAttribute("jsxselected", 1);
                            }
                        }
                    }
                    this.matrix.repaint();
                    return;
                }
                else {
                    this.selection.clear();
                    var nodes = this.matrix.getSelectedNodes();
                    for(var i = 0; i < nodes.size(); i++) {
                        this.selection.add(nodes.getItem(i).getAttribute('name'));
                    }
                }
                if(!this.masterRefreshing && !this.isInEditMode()) {
                    if(this.matrix.getSelectedNodes().getLength() == 1) {
                        var node = this.matrix.getSelectedNodes().getItem(0);
                        this.loadDetailsView(node.getAttribute('type'), node.getAttribute('entityID'),
                                node.getAttribute('name'), node.getAttribute('description'));
                        // send message to edit and delete btns
                        var msg = new Object();
                        msg.subject = plugin.ONITEMSELECTED
                        msg.hasEdit = node.getAttribute("hasEdit");
                        msg.hasOwner = node.getAttribute("hasOwner");
                        tibco.admin.PubSub.publish(msg);

                    }
                    else {
                        if(this.details != null) {
                            var parent = this.mainComponent.getDescendantOfName("paneShdResDefsDetails_25");
                            parent.removeChildren();
                            this.details = null;
                        }
                    }
                }
                this.updateButtons();
            }

            plugin.prototype.updateButtons = function() {
                var nodes = this.matrix.getSelectedNodes();
                var count = nodes.size();
                var notOwner = 0;
                var iter = nodes.iterator();
                while(iter.hasNext()) {
                    var node = iter.next();
                    if(node.getAttribute("hasOwner") != "true") {
                        notOwner++;
                    }
                }
                this.mainComponent.getDescendantOfName("mnbAdd_25A").setEnabled((!this.ignoreSelects) ? jsx3.gui.Form.STATEENABLED : jsx3.gui.Form.STATEDISABLED, true);
                this.mainComponent.getDescendantOfName("btnDelete_25A").setEnabled(((count > 0) && !this.ignoreSelects && (notOwner == 0)) ? jsx3.gui.Form.STATEENABLED : jsx3.gui.Form.STATEDISABLED, true);
                this.mainComponent.getDescendantOfName("selFilterType").setEnabled((!this.ignoreSelects) ? jsx3.gui.Form.STATEENABLED : jsx3.gui.Form.STATEDISABLED, true);
            }

            plugin.prototype.loadDetailsView = function(type, id, name, description) {
                var parent = this.mainComponent.getDescendantOfName("paneShdResDefsDetails_25");
                parent.removeChildren();
                var iter = this.getPluginList().iterator();
                while(iter.hasNext()) {
                    var obj = iter.next();
                    if(obj.getType() == type) {
                        var master = this;
                        this.details = obj.loadComponent(parent, master, id, name, description);
                        break;
                    }
                }
            }

            plugin.prototype.loadDetailsEmpty = function() {
                // TODO: ask plugin to cleanup
            };

            plugin.prototype.add = function(objEvent) {
                this.matrix.deselectAllRecords();
                var parent = this.mainComponent.getDescendantOfName("paneShdResDefsDetails_25");
                parent.removeChildren();
                var type = objEvent.recordNode.getAttribute("type");
                var iter = this.getPluginList().iterator();
                while(iter.hasNext()) {
                    var obj = iter.next();
                    if(obj.getType() == type) {
                        var master = this;
                        this.details = obj.addSharedResourceDefinition(parent, master);
                        return;
                    }
                }
                // TODO: error handling?
                tibco.admin.util.Log.ENVIRONMENT.error(tibco.admin.Main.getServer().getDynamicProperty("@PluginAddErrorMsg", type));
            }

            // End component handling

            // WSDL operations
            // TODO: error handling
            // WSDL operation - getResourceConfigsInEnvironment
            plugin.prototype.callGetConfigurationsInEnterprise = function() {
                var objService = tibco.admin.Main.loadService(this.getNamespace(),
                        "tibco/admin/enterpriseAssets/shdResDefs/rules/getResourceConfigurationsInEnterprise.xml",
                        "getResourceConfigurationsInEnterprise", "Get Shared Resources Configurations")
                objService.setEndpointURL(tibco.admin.util.ServiceHelper.getSharedResourcesEndpointURL());

                //subscribe and call
                var me = this;
                objService.subscribe(jsx3.net.Service.ON_SUCCESS, me, me.onGetResourceConfigurationsInEnterpriseSuccess);
                objService.doCall();
            };

            plugin.prototype.onGetResourceConfigurationsInEnterpriseSuccess = function(objEvent) {
                // TODO: make interface cleaner!!!
                if(this.details) {
                    if(!this.isInEditMode()) {
                        this.details.callGetConfigDetails();
                    }
                    var record = this.matrix.getXML().selectSingleNode("//record[@entityID='" + this.details.id + "']");
                    if(record) {
                        this.masterRefreshing = true;
                        record.setAttribute("jsxselected", 1);
                        this.masterRefreshing = false;
                    }
                }
                else {
                    var iter = this.selection.iterator();
                    while(iter.hasNext()) {
                        var name = iter.next();
                        var record = this.matrix.getXML().selectSingleNode("//record[@name='" + name + "']");
                        if(record) {
                            this.masterRefreshing = true;
                            record.setAttribute("jsxselected", 1);
                            this.masterRefreshing = false;
                        }
                    }
                }
                var selectedFilterValue = this.mainComponent.getDescendantOfName("selFilterType").getValue();
                if(selectedFilterValue != tibco.admin.Main.getServer().getDynamicProperty("@AllTypes")) {
                    this.filterResults();
                }
                else {
                    this.matrix.repaintData();
                }
                this.updateButtons();
                this.tempCacheDoc = this.matrix.getXML().cloneDocument();
                this.nodeSelected();
            };

            // WSDL operation - removeResourceConfigs
            plugin.prototype.callremoveResourceConfigs = function() {
                if(this.details) {
                    parent = this.mainComponent.getDescendantOfName("paneShdResDefsDetails_25").removeChildren();
                    this.details = null;
                }
                var objService = tibco.admin.Main.loadService(this.getNamespace(),
                        "tibco/admin/enterpriseAssets/shdResDefs/rules/removeResourceConfigs.xml",
                        "removeResourceConfigs", "Remove Shared Resource Configurations")
                objService.setEndpointURL(tibco.admin.util.ServiceHelper.getSharedResourcesEndpointURL());

                //subscribe and call
                var me = this;
                objService.subscribe(jsx3.net.Service.ON_SUCCESS, me, me.onremoveResourceConfigsSuccess);
                objService.doCall();
            };

            plugin.prototype.onremoveResourceConfigsSuccess = function(objEvent) {
                tibco.admin.util.ServiceHelper.printInboundOutboundDocument(objEvent);
                this.refreshList();
            };

            plugin.prototype.loadPermissionButtons = function() {
                var domNode = this.mainComponent.getDescendantOfName("panePermissionButtons_25A")
                this.permissions = tibco.admin.Main.loadUIResource(domNode, "tibco.admin", "tibco/admin/enterpriseAssets/userMgt/window/permissions/ui/setPermissions.xml", true)
                this.permissions.initialize("ResourceConfiguration", "entityID", "name", this.matrix)
                var me = this
                this.matrix.switchPermissionBtn = function() {
                    me.permissions.switchPermissionBtn()
                }
            }

            //=========== END OF SET PERMISSION ===============================================

            plugin.prototype.filterResults = function() {
                if(this.tempCacheDoc) {
                    var tempCacheDoc = this.tempCacheDoc;

                    var filterType = this.mainComponent.getDescendantOfName("selFilterType").getValue();

                    if(filterType == tibco.admin.Main.getServer().getDynamicProperty("@AllTypes")) {
                        filterType = "All";
                    }
                    this.matrix.setXMLTransformers(tibco.admin.Main.resolveURI("tibco.admin", "tibco/admin/enterpriseAssets/shdResDefs/xsl/transform.xsl"));
                    this.matrix.setXSLParam("type", filterType);
                    this.matrix.setSourceXML(tempCacheDoc);
                    this.matrix.repaintData();
                }
            }

            plugin.prototype.tabSelected = function() {
                this.onRefresh();
            }

            plugin.prototype.beginEdit = function(obj) {
                this.ignoreSelects = true;
                this.updateButtons();
            }

            plugin.prototype.endEdit = function(obj) {
                this.ignoreSelects = false;
                this.updateButtons();
            }
        });
